package com.kunpeng.weibo.sina.api;

import com.kunpeng.weibo.sina.SinaWeibo;
import com.kunpeng.weibo.sina.beans.Oauth2AccessToken;
import com.kunpeng.weibo.sina.beans.WeiboParameters;
import com.kunpeng.weibo.sina.http.HttpTask;

/**
 * 关系相关接口
 * 
 * @author Lee
 * @date 2012-4-23
 * @Description TODO
 */
public class Friendships_API extends Request_API {

	public Friendships_API(Oauth2AccessToken accessToken) {
		super(accessToken);
	}

	/**
	 * 关注一个用户
	 * 
	 * @param uid 需要关注的用户ID。
	 * @param screenName 需要关注的用户昵称。
	 */
	public int create(int uid, String screenName) {
		if (mAccessToken == null) {
			throw new NullPointerException();
		}
		String url = "https://api.weibo.com/2/friendships/create.json";
		WeiboParameters parameters = new WeiboParameters();
		parameters.add("source", SinaWeibo.SINA_APP_KEY);
		parameters.add("uid", String.valueOf(uid));
		if (screenName != null && !screenName.equals("")) {
			parameters.add("screen_name", screenName);
		}
		return new HttpTask().openUrl(url, HttpTask.HTTPMETHOD_POST, parameters, mAccessToken);
	}
}
